import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/layout'

Vue.use(VueRouter)

const routes = [
    // 登录页
    {path: '/login', name: 'login', component: () => import('@/views/login'), meta: {title: '登录'}},
    // 主页
    {
        path: '/',
        component: Layout,
        redirect: '/classification',
        children: [
            {
                path: '/classification',
                name: 'classification',
                component: () => import('@/views/classification'),
                meta: {title: '菜品分类'}
            },
            {path: '/cart', name: 'cart', component: () => import('@/views/cart'), meta: {title: '购物车'}},
            {path: '/order', name: 'order', component: () => import('@/views/order'), meta: {title: '订单管理'}},
            {path: '/dish', name: 'dish', component: () => import('@/views/dish'), meta: {title: '菜品管理'}},
            {
                path: '/edit-dish',
                name: 'edit-dish',
                component: () => import('@/views/dish/edit-dish'),
                meta: {activeMenu: '/dish', title: '菜品编辑'}
            },
            {
                path: '/category',
                name: 'category',
                component: () => import('@/views/category'),
                meta: {title: '菜品类目'}
            },
        ]
    },
    {path: '/404', component: () => import('@/views/404')},
    {path: '*', redirect: '/404'}
]

const router = new VueRouter({
    routes
})

export default router
